package tagdb.fragmentation;


import tagdb.algorithm.graph.Edge;

import java.util.ArrayList;
import java.util.List;

public class SpectrumPeak implements Peak {

    /**
     * This double holds the m/z.
     */
    private double iMz;
    /**
     * This double holds the intensity.
     */
    private double iIntensity;
    /**
     * This Integer holds the charge.
     */
    private int iCharge;

    private List<Edge> edges;

    /**
     * Empty constructor for a spectrum peak.
     */
    public SpectrumPeak() {
    }

    /**
     * Constructor gets the m/z and the intensity.
     *
     * @param aMz
     * @param aIntensity
     */
    public SpectrumPeak(double aMz, double aIntensity) {
        iMz = aMz;
        iIntensity = aIntensity;
    }

    /**
     * Constructor gets the m/z, the intensity and the charge.
     *
     * @param aMz
     * @param aIntensity
     * @param aCharge
     */
    public SpectrumPeak(double aMz, double aIntensity, int aCharge) {
        iMz = aMz;
        iIntensity = aIntensity;
        iCharge = aCharge;
    }

    /**
     * Check whether this peak equals to another peak.
     * @param peak Comparable peak.
     * @return true if the peaks are equal
     */
    public boolean equals(SpectrumPeak peak) {
        if(this.iMz == peak.getMZ() && this.iIntensity == peak.getIntensity()) {
            return true;
        }
        else {
            return false;
        }
    }

    /**
     * Sets the charge.
     *
     * @param aCharge
     */
    public void setCharge(int aCharge) {
        iCharge = aCharge;
    }

    /**
     * Returns the charge.
     *
     * @return the charge
     */
    public int getCharge() {
        return iCharge;
    }

    /**
     * Sets the intensity.
     *
     * @param aIntensity
     */
    public void setIntensity(double aIntensity) {
        iIntensity = aIntensity;
    }

    /**
     * Returns the intensity.
     *
     * @return the intensity
     */
    public double getIntensity() {
        return iIntensity;
    }

    /**
     * Sets the m/z.
     *
     * @param aMz
     */
    public void setMz(double aMz) {
        iMz = aMz;
    }

    /**
     * Returns the m/z.
     *
     * @return the m/z
     */
    public double getMZ() {
        return iMz;
    }

    /**
     * Adds an edge to the spectrum peak node.
     * 
     * @param e Edge
     */
    public void addEdge(Edge e){
        if(edges == null){
            edges = new ArrayList<Edge>();
        }
        edges.add(e);
    }

    /**
     * Returns the list of connected edges
     * 
     * @return the list of connected edges
     */
    public List<Edge> getEdges() {
        return edges;
    }
}
